package ms.aurora.app;

import com.google.common.collect.Maps;

import javax.swing.*;
import java.awt.*;
import java.util.Map;

public abstract class AppWindow extends JFrame {
    private final Map<String, Container> slotMapping = Maps.newHashMap();

    public void setInSlot(String slotName, Component view) {
        if (!slotMapping.containsKey(slotName))
            throw new RuntimeException("Slot " + slotName + " is undefined.");
        Container slot = slotMapping.get(slotName);
        slot.removeAll();
        slot.add(view);
        validate();
    }

    public void registerSlot(String name, Container container) {
        slotMapping.put(name, container);
    }

    public void unregisterSlot(String name) {
        slotMapping.remove(name);
    }
}
